package com.jintian.smart.kernel.orm.function;

import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Map;

public class UtilsFunction {
    public int length(Object obj) {
        if (obj == null) {
            return 0;
        }
        if (obj instanceof Map) {
            return ((Map) obj).size();
        } else if (obj instanceof Collection) {
            return ((Collection) obj).size();
        } else if (obj.getClass().isArray()) {
            if (obj == null) {
                return 0;
            }
            return Array.getLength(obj);
        }
        return 0;
    }
}
